#!/bin/bash
echo "创建用户账户……"

read -p "请输入要创建的用户账户名：" userName
if grep -q "^$userName" /etc/passwd             //-q  不显示用户信息
then
      echo "输入的用户名已经存在。"
      echo "===================================="
      echo "创建用户账号失败"
      exit 1
else
      read -p "请输入用户账户登录密码" -s userPass
      useradd $userName
      echo "$userPass" | passwd --stdin $userName >> /dev/null
      echo "========================================"
      echo "创建用户成功"
     exit 0
fi
